<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>添加管理角色</title>
    <link rel="stylesheet" type="text/css" href="/static/h+/css/bootstrap.min.css">
    <link rel="stylesheet" type="text/css" href="/static/h+/css/font-awesome.min93e3.css?v=4.4.0">
    <!-- Data Tables -->
    <link rel="stylesheet" type="text/css" href="/static/h+/css/bootstrap.min.css">
    <link rel="stylesheet" type="text/css" href="/static/h+/css/style.min.css?v=4.1.0">
    <link rel="stylesheet" type="text/css" href="/static/layer/skin/layer.css">
    <link rel="stylesheet" type="text/css" href="/static/uploadifive/uploadifive.css">
    <style type="text/css">
        .form-control{width: 200px;}
    </style>
</head>
<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
  <div class="row">
    <div class="col-sm-12">
      <div class="ibox float-e-margins">
        <div class="ibox-title">
          <h5>添加管理角色</h5>
        </div>
        <div class="ibox-content">
          <form class="form-horizontal" onsubmit="return false">
            <div class="form-group">
              <label class="col-sm-2 control-label">角色名称</label>
                <div class="col-sm-10">
                  <input type="text" class="form-control" id="role_name">
                </div>
            </div>
            <div class="hr-line-dashed"></div>
            <div class="form-group">
              <div class="col-sm-4 col-sm-offset-2">
                <input class="btn btn-primary" type="button" data-action="save" value="保存内容">
                <input class="btn btn-white" type="button" data-action="cancel" value="取消">
              </div>
            </div>
          </form>
        </div>
      </div>
    </div>
  </div>
</div>
</body>
<script type="text/javascript" src="/static/h+/js/jquery.min.js"></script>
<script type="text/javascript" src="/static/layer/layer.js"></script>
<script type="text/javascript" src="/static/uploadifive/jquery.uploadifive.js"></script>
<script type="text/javascript">
    $(function(){
        $('input[data-action]').click(function(){
            $action = $(this).data('action');
            if ($action == 'save') {
                var role_name = $('#role_name');
                if (role_name.val() == '') {
                    layer.msg('角色名称不能为空', {icon: 5, time: 1000}, function(){role_name.focus()});
                    return false
                }
                $.ajax({
                    type: 'post', cache: false, dataType: 'json',
                    url: '{:url("add")}',
                    data: {'role_name': role_name.val()},
                    success: function(data){
                        if (data.status == 0) {
                            layer.msg(data.info, {icon: 6, time: 1000});
                            // layer.confirm(data.info + '<br />是否继续添加？', {
                            //     btn: ['是', '否'],
                            //     shade: false,
                            //     closeBtn: 0
                            // }, function(){
                            //     location.reload()
                            // }, function(){
                            //     location.href = '/admin/list'
                            // })
                        }else{
                            layer.msg(data.info, {icon: 5, time: 1000});
                        }
                    }
                })
            } else if ($action == 'cancel') {
                location.href = '{:url("lists")}'
            }
        });
    });
</script>
</html>